<#import '/ftlLibrary/properteisVariable.ftl' as pv/>
<style>
    .bootbox-close-button {
        width: 19px;
        height: 19px;
        border: none;
        cursor: pointer;
        -webkit-appearance: none;
        float: right;
        top: 4px;
        left: -5px;
        position: relative;
        background: #E9F5FF url("assets/img/nav-img/icon_close.png") no-repeat 0 0;
    }
    .tssCourseEdit .modal-dialog {
        width: 60% !important;
    }

    .tssCourseEdit .modal-body {
        padding-bottom: 0;
    }
    input,select{
        height: 30px!important;
        border-radius: 5px!important;
    }
</style>
<div class="col-lg-12 col-sm-12 col-xs-12">
    <div class="modal-header">
        <button type="button" class="bootbox-close-button close" data-dismiss="modal" aria-hidden="true">×</button>
        <h4 class="modal-title">${(editModel=='add')?string('新增过渡课程','编辑过渡课程')}</h4>
    </div>
    <div class="modal-body" style="padding-top: 0px!important">
        <div class="row">
            <form class="editForm" action="${saveUrl}" method="post" responseType="JSON" role="form"
                  id="editForm_${serializeNum}"
                  data-bv-submitButtons="#editFormSubmitBtn_${serializeNum}"
                  data-bv-message="This value is not valid"
                  data-bv-feedbackicons-valid="glyphicon glyphicon-ok"
                  data-bv-feedbackicons-invalid="glyphicon glyphicon-remove"
                  data-bv-feedbackicons-validating="glyphicon glyphicon-refresh">
                <input type="hidden" name="id" value="${editEntity.id}">
                <input type="hidden" name="type"  value="2">
                <input type="hidden" name="isBlockUp"  value="${editEntity.isBlockUp}">

                <div class="col-xm-12 col-sm-12 col-lg-12 margin-top-20">
                    <div class="form-group">
                        <label
                               class="col-sm-2 col-sm-offset-3 control-label no-padding-right"><span style="color: red">*</span>课程体系：</label>
                        <div class="col-sm-4">
                            <select name="systemPid" class="systemPid col-sm-12" value="${editEntity.systemPid}" required="required" data-bv-message="请选择课程体系">
                            </select>
                        </div>
                    </div>
                </div>

                <div class="col-xm-12 col-sm-12 col-lg-12">
                    <div class="form-group">
                        <label
                                class="col-sm-2 col-sm-offset-3 control-label no-padding-right"><span style="color: red">*</span>课程名称：</label>
                        <div class="col-sm-4">
                            <select name="systemId" class="systemId col-sm-12" value="${editEntity.systemId}" required="required" data-bv-message="请选择课程名称">
                                <option value="">请选择</option>
                            </select>
                        </div>
                    </div>
                </div>

                <div class="col-sm-12">
                    <div class="text-align-center ">
                        <button style="min-width: 80px;margin-right:20px" type="submit" class="btn btn-blue" id="editFormSubmitBtn_${serializeNum}">确定
                        </button>
                        <button style="width: 80px" type="button" class="btn btn-blue" data-dismiss="modal">取消
                        </button>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
<script src="assets/js/validation/bootstrapValidator_init.js"></script>
<script>
    $(".selectpicker_${serializeNum}").select2();

    $("#editForm_${serializeNum}").bind("ajaxSubmitCallback", function (event, result) {
        if (result.resCode == 200) {
            bootbox.hideAll();
            logger.info(result.resMsg, true);
            toView('tssCourseController/tssCourseList.do?type=2',true,'POST',{pageSize:10})
        } else {
            logger.error(result.resMsg);
        }
    });

    /**
     * 获取课程体系
     */
    $(function(){
        ajaxRequest("sysCourseSystemController/courseSystemList.do",{
            type:2
        }, function (result) {
            var data=result.data;
            var arr=['<option value="">请选择</option>'];
            var value = $(".systemPid").attr("value");
            $.each(data,function(i,t){
                if( value == t.id){
                    arr.push('<option value="'+t.id+'" selected="selected">'+t.name+'</option>')
                } else {
                    arr.push('<option value="'+t.id+'">'+t.name+'</option>')
                }
            })
            $(".systemPid").html(arr.join(''))

            if(value){
                ajaxRequest("sysCourseSystemController/getChildrens.do", {
                    pId: value
                }, function (result) {
                    var data=result.data;
                    var arr=['<option value="">请选择</option>'];
                    var value = $(".systemId").attr("value");
                    $.each(data,function(i,t){
                        if( value == t.id){
                            arr.push('<option value="'+t.id+'" selected="selected">'+t.name+'</option>')
                        } else {
                            arr.push('<option value="'+t.id+'">'+t.name+'</option>')
                        }
                    })
                    $(".systemId").html(arr.join(''))

                }, function () {
                    ajaxError("加载城市失败")
                }, "get", "json")
            }
        },function(){
            ajaxError("加载课程体系失败");
        }, "get","json")
    });

    /**
     * 获取课程体系下课程名称
     */
    $(".systemPid").change(function(){
        var nowSelectedProvince=$(this).val();
        ajaxRequest("sysCourseSystemController/getChildrens.do", {
            pId: nowSelectedProvince
        }, function (result) {
            var data=result.data;
            var arr=['<option value="">请选择</option>'];
            $.each(data,function(i,t){
                arr.push('<option value="'+t.id+'">'+t.name+'</option>')
            })
            $(".systemId").html(arr.join(''))

        }, function () {
            ajaxError("加载城市失败")
        }, "get", "json")
    });

</script>